Skip to content

HY/CRTX-287602/ServicenowEvents - #46420

Open
hyaffe839 wants to merge 11 commits into
masterfrom
HY/CRTX-287602/ServicenowEvents
Open

hyaffe839 wants to merge 11 commits into
masterfrom
HY/CRTX-287602/ServicenowEvents

Conversation

@hyaffe839

@hyaffe839 hyaffe839 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Contributing to Cortex XSOAR Content

Make sure to register your contribution by filling the contribution registration form

The Pull Request will be reviewed only after the contribution registration form is filled.

Status

  • In Progress
  • Ready
  • In Hold - (Reason for hold)

Related Issues

Description

Added the servicenow-create-event command to the ServiceNow v2 integration, enabling creation of events in ServiceNow Event Management via the /api/global/em/jsonv2 webhook.

What's new:

  • New command servicenow-create-event with arguments: source (defaults to "Cortex"), node, type, time_of_event (required), resource, severity, description, additional_info, message_key, resolution_state.
  • Severity labels (critical, high, medium, low, info) are automatically mapped to ServiceNow integer values (1–5).
  • Resolution state labels (new, in progress, resolved) are mapped to ServiceNow values (open, closed).
  • A corresponding quick action (servicenow-create-event-quick-action) is included for use from the Cortex UI.

Must have

  • Tests
  • Documentation

@hyaffe839 hyaffe839 self-assigned this Oct 29, 2026
@hyaffe839 hyaffe839 added docs-approved ready-for-pipeline-running Whether the pr is ready for running the whole pipeline, including testing on SAAS machines ready-for-ai-review The PR is ready for reviewing the PR with the AI Reviewer. labels Oct 29, 2026
@hyaffe839
hyaffe839 marked this pull request as draft October 29, 2026 14:27
@content-bot

Copy link
Copy Markdown
Contributor

🤖 AI-Powered Code Review Available

You can leverage AI-powered code review to assist with this PR!

Available Commands:

  • @marketplace-ai-reviewer start review - Initiate a full AI code review
  • @marketplace-ai-reviewer re-review - Incremental review for new commits

@marketplace-ai-reviewer marketplace-ai-reviewer removed the ready-for-ai-review The PR is ready for reviewing the PR with the AI Reviewer. label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Coverage

Coverage Report
FileStmtsMissCoverMissing
Packs/ServiceNow/Integrations/ServiceNowv2
   ServiceNowv2.py161428282%219, 231, 237, 485, 487, 491, 516, 557, 564–565, 603–604, 731–734, 744, 754–764, 775, 786–787, 859–860, 867, 873–879, 890–891, 904, 908, 921, 947, 949, 951–952, 954–955, 957–960, 962, 1004, 1009, 1037–1042, 1045, 1048, 1159, 1288–1289, 1317–1323, 1325, 1328–1329, 1331–1334, 1336, 1338–1339, 1341, 1343–1344, 1346–1347, 1349, 1372–1373, 1375, 1384–1385, 1416, 1455, 1458, 1465, 1493, 1498, 1586, 1641, 1689, 1741, 1822, 1884, 1887, 1937, 1939–1941, 1943–1944, 1999, 2002–2004, 2018, 2023–2025, 2051, 2086–2087, 2095, 2146, 2190–2193, 2195, 2198, 2205, 2268–2273, 2275–2276, 2278–2280, 2282–2283, 2285–2287, 2289–2290, 2292, 2294, 2306, 2309, 2311, 2324–2329, 2331–2332, 2334–2336, 2338–2339, 2341–2343, 2345–2346, 2348, 2360–2361, 2364, 2366, 2384, 2387, 2415, 2418, 2452, 2455, 2459, 2487, 2527, 2553, 2583, 2681, 2693, 2704, 2707, 2711–2712, 2716, 2718–2719, 2791, 2797, 2808, 2856–2857, 2898–2901, 2923–2924, 2928–2929, 2964, 2968, 2974, 3070, 3073–3075, 3206–3210, 3212–3213, 3217–3218, 3273–3274, 3300, 3438, 3440, 3444–3445, 3620–3622, 3628, 3645, 3648, 3652, 3683, 3763, 3846–3847, 3852, 3868, 3889, 3910–3912, 3931–3933, 3975, 3983, 4039–4041, 4043, 4045, 4047, 4049, 4051, 4053, 4055, 4057, 4059, 4061, 4065, 4067, 4069, 4071–4072, 4077–4078, 4086
TOTAL161428282% 

Tests Skipped Failures Errors Time
192 0 💤 0 ❌ 0 🔥 27523489m 44s ⏱️

@marketplace-ai-reviewer

Copy link
Copy Markdown
Contributor

🤖 Analysis started. Please wait for results...

marketplace-ai-reviewer

This comment was marked as outdated.

@content-bot

This comment has been minimized.

@content-bot

This comment has been minimized.

@content-bot

This comment has been minimized.

@content-bot

This comment has been minimized.

@content-bot

This comment has been minimized.

@hyaffe839 hyaffe839 added the ready-for-ai-review The PR is ready for reviewing the PR with the AI Reviewer. label Nov 11, 2026
@marketplace-ai-reviewer marketplace-ai-reviewer removed the ready-for-ai-review The PR is ready for reviewing the PR with the AI Reviewer. label Nov 11, 2026
@marketplace-ai-reviewer

Copy link
Copy Markdown
Contributor

🤖 Analysis started. Please wait for results...

marketplace-ai-reviewer

This comment was marked as outdated.

@hyaffe839
hyaffe839 marked this pull request as ready for review November 11, 2026 16:14
@hyaffe839

Copy link
Copy Markdown
Contributor Author

@marketplace-ai-reviewer start review

@marketplace-ai-reviewer

Copy link
Copy Markdown
Contributor

🤖 Analysis started. Please wait for results...

@content-bot

Copy link
Copy Markdown
Contributor

Validate summary
If the AG100 validation in the pre-commit GitHub Action fails, the pull request cannot be force-merged.

Verdict: PR can be force merged from validate perspective? ✅

@marketplace-ai-reviewer

Copy link
Copy Markdown
Contributor
🤖 AI Review Disclaimer

This review was generated by an AI-powered tool and may contain inaccuracies. Please be advised, and we extend our sincere apologies for any inconvenience this may cause.

@marketplace-ai-reviewer marketplace-ai-reviewer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there, thanks for your contribution!

Overall, the new command looks great, but we noticed a few areas that need attention before merging:

  • Command Logic: Please add input validation for required arguments, safely handle non-string severity values to avoid type errors, and make sure to capture and return the raw API response in CommandResults.
  • YAML Standards: Fix schema key casing (e.g., defaultvalue) and ensure argument descriptions follow the standard formatting guidelines.
  • Release Notes & Versioning: Since this introduces a new command, bump the minor version (e.g., to 2.11.0) per semver guidelines and format the command name with bold-italics.

Once these updates are in place, we should be good to go!

Additionally, please address the following file-level notes:

  • Packs/ServiceNow/ReleaseNotes/2_10_13.md: The release notes describe adding a new command (servicenow-create-event), which represents a feature addition. Under semantic versioning rules, adding new functionality requires a minor version bump (e.g., 2.11.0 and 2_11_0.md), whereas a revision/patch bump (2.10.13) is reserved only for bug fixes.

Please update currentVersion in Packs/ServiceNow/pack_metadata.json to a minor version bump and rename the release notes file accordingly, or run:

demisto-sdk update-release-notes -i Packs/ServiceNow -u minor

For more information, refer to the Release Notes Documentation.

@marketplace-ai-reviewer, @omerKarkKatz, @hyaffe839 please review and approve the results generated by the AI Reviewer by responding 👍 on this comment.


client.create_event([event])

return CommandResults(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please assign the response from client.create_event([event]) and pass it to CommandResults as raw_response.

    response = client.create_event([event])

    return CommandResults(
        readable_output="Event successfully sent to ServiceNow Event Management.",
        raw_response=response,
    )

"resolved": "closed",
}

node = args.get("node")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring specifies that node, type, and time_of_event are required fields and that a DemistoException is raised if any are missing, but the function does not validate their presence before constructing the event. If omitted, None values are sent to ServiceNow.

Consider adding explicit validation:

Suggested change
node = args.get("node")
node = args.get("node")
event_type = args.get("type")
time_of_event = args.get("time_of_event")
missing = [name for name, val in (("node", node), ("type", event_type), ("time_of_event", time_of_event)) if not val]
if missing:
raise DemistoException(f"Missing required argument(s): {', '.join(missing)}")

event[field] = value

if (severity := args.get("severity")) is not None:
event["severity"] = severity_map.get(severity.lower(), severity)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If severity is provided as a non-string type (such as an integer from playbook context, e.g., severity=1), calling .lower() will raise an AttributeError.

Consider casting to str before calling .lower():

Suggested change
event["severity"] = severity_map.get(severity.lower(), severity)
event["severity"] = severity_map.get(str(severity).lower(), str(severity))

if (resolution_state := args.get("resolution_state")) is not None:
event["resolution_state"] = resolution_state_map.get(resolution_state.lower(), resolution_state)

client.create_event([event])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring states that CommandResults returns the raw ServiceNow response, but the return value of client.create_event([event]) is currently ignored and raw_response is not passed to CommandResults.

Consider capturing the response and including it in CommandResults:

Suggested change
client.create_event([event])
response = client.create_event([event])
return CommandResults(
readable_output="Event successfully sent to ServiceNow Event Management.",
raw_response=response,
)

description: state of task.
type: Unknown
- arguments:
- defaultValue: Cortex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- defaultValue: Cortex
- defaultvalue: Cortex

According to Cortex XSOAR YAML formatting standards, schema keys are case-sensitive and should use lowercase (e.g., defaultvalue instead of defaultValue). Please update this key here and in the quick-action arguments on line 2052.

type: Unknown
- arguments:
- defaultValue: Cortex
description: Source of the event.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: Source of the event.
description: The source of the event.

Argument descriptions should follow the descriptive form starting with "The " and ending with a period (e.g., "The source of the event."). Please apply this convention across the other newly added argument descriptions as well.


- arguments:
- defaultValue: Cortex
description: Source of the event. Defaults to "Cortex".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: Source of the event. Defaults to "Cortex".
description: The source of the event.

Since a default value is defined in the argument's defaultvalue field, remove "Defaults to "Cortex"." from the description. The defaultvalue field serves as the single source of truth. Additionally, start the description with "The " per description guidelines.


##### ServiceNow v2

- Added the new **servicenow-create-event** command, which creates an event in ServiceNow Event Management.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command names should be formatted in bold-italics (***command-name***) rather than bold per the Entity Styling guidelines.

Suggested change
- Added the new **servicenow-create-event** command, which creates an event in ServiceNow Event Management.
- Added the new ***servicenow-create-event*** command, which creates an event in ServiceNow Event Management.

@content-bot

Copy link
Copy Markdown
Contributor

🔍 AI Triage Report Available

An automated triage report has been generated for this pipeline.

Status: failed
Report ID: 65b95be28b366530

📋 Triage Report
💡 Resolutions are available in the full report.

⚠️ AI-generated triage. Validate before acting.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-approved ready-for-pipeline-running Whether the pr is ready for running the whole pipeline, including testing on SAAS machines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants